package io.github.lee.repository.qb.dao

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object SessionDatabaseModel {
    @Provides
    fun provideDatabase(@ApplicationContext context: Context): SessionDatabase {
        return Room
            .databaseBuilder(context, SessionDatabase::class.java, "session.db")
            .build()
    }

    @Singleton
    @Provides
    fun provideUserDao(database: SessionDatabase): SessionDao {
        return database.sessionDao()
    }

}
